package me.firstapp.manage.emailConfig;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import me.firstapp.common.json.SingleObject;
import me.firstapp.common.module.system.JsonEmailConfig;
import me.firstapp.manage.common.BaseManage;
import me.firstapp.spi.system.EmailConfigService;

@Controller
@RequestMapping(value = "/emailConfigManage")
public class EmailConfigManagePage extends BaseManage {

	@Autowired
	private EmailConfigService emailConfigService;

	@RequestMapping(value = "/mailConfigList.html", method = RequestMethod.GET)
	public ModelAndView mailConfigListView(HttpServletRequest request, HttpServletResponse response,
			ModelMap modelMap) {
		return new ModelAndView("mailConfig/mailConfigList", modelMap);
	}

	@RequestMapping(value = "/mailConfigUpdate.html", method = RequestMethod.GET)
	public ModelAndView mailConfigUpdateView(Long id, HttpServletRequest request, HttpServletResponse response,
			ModelMap modelMap) {
		SingleObject<JsonEmailConfig> result = emailConfigService.findEmailConfigById(id);
		modelMap.put("mailConfig", result.getObject());
		modelMap.put("id", id);
		return new ModelAndView("mailConfig/mailConfigUpdate", modelMap);
	}

	@RequestMapping(value = "/mailConfigAdd.html", method = RequestMethod.GET)
	public ModelAndView mailConfigAddView(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
		return new ModelAndView("mailConfig/mailConfigAdd", modelMap);
	}
}
